<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>登录</title>
    <link rel="stylesheet" href="__PUBLIC__/css/bootstrap.min.css">
    <script src="__PUBLIC__/js/jquery.js"></script>
    <script src="__PUBLIC__/js/bootstrap.min.js"></script>
    <style>
        body{background-image: url("__PUBLIC__/image/0.jpg");}
    </style>
</head>
<body>
<div class="col-xs-12 col-xs-offset-12 col-sm-6 col-sm-offset-3 col-md-6 col-md-offset-3">
<div class="panel panel-primary">
    <div class="panel-heading">
        <h3 class="panel-title">登录</h3>
    </div>
    <div class="panel-body">
        <form onsubmit="return false">
            <div class="form-group">
                <label for="exampleInputEmail1">用户名</label>
                <input type="text" name="name" class="form-control" id="exampleInputEmail1" placeholder="用户名">
            </div>
            <div class="form-group">
                <label for="exampleInputPassword1">密码</label>
                <input type="password" name="pwd" class="form-control" id="exampleInputPassword1" placeholder="密码">
            </div>
            <button type="submit" class="btn btn-primary" id="js_btn">登录</button>
        </form>
        <div class="modal fade" id="myModal">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title">提示框</h4>
                    </div>
                    <div class="modal-body">
                        <p style="font-size: 40px;">出错啦&hellip;</p>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                    </div>
                </div><!-- /.modal-content -->
            </div><!-- /.modal-dialog -->
        </div><!-- /.modal -->
        <script>
            $("#js_btn").click(function(){
                var name=$("#exampleInputEmail1").val();
                var pwd=$("#exampleInputPassword1").val();

                $.ajax({
                    type:"POST",        //发送格式
                    url:"{:U('dologin')}",   //发送到哪里
                    async:true,        // 设置格式(异步)   默认异步
                    data:{'name':name,'pwd':pwd},  //发送的参数
                    dataType:'json',
                    success:function(data){
                        if(data){
                        window.location.href="{:U('Index/index')}";  //跳转
                        }else{
                            $('#myModal').modal('show');
                        }
                    }
                })
            })

        </script>
    </div>
</div>
    </div>
</body>
</html>